var hisAutidGridStore = null;
var businessIdParam = null;
Ext.define("component.his.audit.records",{
	extend : 'Ext.panel.Panel',
	config : {
		businessId: '',
		businessType: '',
		contextPath:contextPath,
		showGrid: ''
	},
	loadNrrAuditRecord: function(businessId){
		businessIdParam = businessId;
		hisAutidGridStore.load();
	},
	initComponent : function() {
		var businessId = this.businessId;
		var businessType = this.businessType;
		var contextPath = this.contextPath;
		var showGrid = this.showGrid=="true"?true:false;
		hisAutidGridStore = Ext.create('Ext.data.Store', {
	        fields: ["procinstName", "startTime", "endTime", "originDelayDate", "delayDate", "delayDays", "auditStatus"],
	        pageSize: 10,  //页容量10条数据
	        //是否在服务端排序 （true的话，在客户端就不能排序）
	        remoteSort: false,
	        proxy: {
	            type: 'ajax',
	            url: contextPath+'/activitiInfo/hisAuditRecordList',
	            actionMethods: { read: 'POST' },
	            reader: {   //这里的reader为数据存储组织的地方，下面的配置是为json格式的数据，例如：[{"total":50,"rows":[{"a":"3","b":"4"}]}]
	                type: 'json', //返回数据类型为json格式
	                root: 'rows',  //数据
	                totalProperty: 'total' //数据总条数
	            }
	        },
	        autoLoad: true  //即时加载数据
	    });
		
		hisAutidGridStore.on("beforeload",function(){
			if(businessIdParam){
				hisAutidGridStore.getProxy().extraParams.businessId = businessIdParam;
			}else{
				hisAutidGridStore.getProxy().extraParams.businessId = businessId;
			}
      		hisAutidGridStore.getProxy().extraParams.businessType = businessType;
	    });
		
		var hisAuditGrid = Ext.create('Ext.grid.Panel', {
		    store: hisAutidGridStore,
		    minHeight: 100,
		    columns: [
		        {text: '流程名称',  dataIndex: 'procinstName', minWidth: "150"},
		        {text: '流程申请时间', dataIndex: 'startTime', minWidth: "150"},
		        {text: '流程终审时间', dataIndex: 'endTime', minWidth: "150"},
		        {text: '原始日期', dataIndex: 'originDelayDate'},
		        {text: '申请日期', dataIndex: 'delayDate'},
		        {text: '延期天数', dataIndex: 'delayDays'},
		        {text: '审核状态', dataIndex: 'auditStatus'}
		    ],
		    viewConfig:{
		    	forceFit: true,//列宽度自适应
		    	scrollOffset: 0,//去除最右边空白
		    	flex: 1
	    	}
		});
		
		var defaultConfig = {
			margin: "10 0 0 0",
			title:"历史审批记录",
			hidden: !showGrid,
			items:[hisAuditGrid]
		};
		
		Ext.apply(this,defaultConfig);
		this.callParent();
	}
});
